/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.wallet
 * WalletController.java
 * 创建人:小胡
 * 时间：2017年01月24日 08:51:16
 *
 */
package com.tz.web.wallet;

import com.tz.auth.AuthPassport;
import com.tz.bean.TzParams;
import com.tz.bean.Wallet;
import com.tz.service.wallet.IWalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * 虚拟账户管理web
 * WalletController
 * 创建人:小胡
 * 时间：2017年01月24日 08:51:16
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/wallet")
public class WalletController {
	
	@Autowired
	private IWalletService walletService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/list")
	public String list(TzParams params){
		return "wallet/list";
	}

    /*模板页面*/
	@RequestMapping("/template")
	public String template(TzParams params ,Model model){
		model.addAttribute("datas", walletService.findWallets(params));
		model.addAttribute("itemCount", walletService.count(params));
		return "wallet/template";
	}

	@ResponseBody
	@RequestMapping(value="/update",method= RequestMethod.POST)
	public String update(Wallet wallet){
		walletService.update(wallet);
		return "success";
	}


	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		walletService.delete(params);
		return "success";
	}
	@RequestMapping("/add")
    public String add(TzParams params){
		return "wallet/add";
   }


	@RequestMapping(value = "/edit/{id}" ,method = RequestMethod.GET)
    public String edit(@PathVariable("id") Integer id , Model model){
		HashMap<String ,Object> wallet = walletService.getWallet(id);
		model.addAttribute("wallet",wallet);
		return "wallet/edit";
	}
}
